﻿using System;
using System.Collections.Generic;
using System.Linq;
using Engine;
using Game.NetWork;
using GameEntitySystem;
using MFTrain;
using TemplatesDatabase;

namespace Game
{
    public class FCSubsystemCreatureSpawn : SubsystemCreatureSpawn, IUpdateable
    {
        public Entity FCSpawnCreature(string templateName, Vector3 position, bool constantSpawn, ComponentMiner componentMiner, TerrainRaycastResult? terrainRaycastResult)
        {
            try
            {
                Entity entity = DatabaseManager.CreateEntity(base.Project, templateName, throwIfNotFound: true);
                Vector3 vector = componentMiner.ComponentCreature.ComponentCreatureModel.EyeRotation.ToForwardVector2();
                entity.FindComponent<ComponentMFTrain>(throwOnError: true).SetDirection((!MFRailBlock.IsDirectionX(MFRailBlock.GetRailType(Terrain.ExtractData(terrainRaycastResult.Value.Value)))) ? ((vector.X < 0f) ? 1 : 3) : ((!(vector.Z < 0f)) ? 2 : 0));
                ComponentBody componentBody = entity.FindComponent<ComponentBody>();
                componentBody.Position = position;
                componentBody.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitY, m_random.Float(0f, (float)Math.PI * 2f));
                entity.FindComponent<ComponentSpawn>(throwOnError: true).SpawnDuration = 0f;
                ComponentCreature componentCreature = entity.FindComponent<ComponentCreature>();
                if (componentCreature != null)
                {
                    componentCreature.ConstantSpawn = constantSpawn;
                }

                base.Project.AddEntity(entity);
                return entity;
            }
            catch (Exception ex)
            {
                Log.Error("Unable to spawn creature with template \"" + templateName + "\". Reason: " + ex.Message);
                return null;
            }
        }

        public new void SpawnRandomCreature()
        {
            if (CountCreatures(constantSpawn: false) >= 24 * ProjectNet.subsystemPlayers.PlayersData.Count)
            {
                return;
            }

            foreach (GameWidget gameWidget in m_subsystemViews.GameWidgets)
            {
                Vector2 vector = new Vector2(gameWidget.ActiveCamera.ViewPosition.X, gameWidget.ActiveCamera.ViewPosition.Z);
                if (CountCreaturesInArea(vector - new Vector2(60f), vector + new Vector2(60f), constantSpawn: false) >= 48)
                {
                    break;
                }

                SpawnLocationType spawnLocationType = GetRandomSpawnLocationType();
                Point3? spawnPoint = GetRandomSpawnPoint(gameWidget.ActiveCamera, spawnLocationType);
                if (spawnPoint.HasValue)
                {
                    Vector2 c2 = new Vector2(spawnPoint.Value.X, spawnPoint.Value.Z) - new Vector2(16f);
                    Vector2 c3 = new Vector2(spawnPoint.Value.X, spawnPoint.Value.Z) + new Vector2(16f);
                    if (CountCreaturesInArea(c2, c3, constantSpawn: false) >= 4)
                    {
                        break;
                    }

                    IEnumerable<CreatureType> source = m_creatureTypes.Where((CreatureType c) => c.SpawnLocationType == spawnLocationType && c.RandomSpawn);
                    IEnumerable<float> items = source.Select((CreatureType c) => c.SpawnSuitabilityFunction(c, spawnPoint.Value));
                    int randomWeightedItem = GetRandomWeightedItem(items);
                    if (randomWeightedItem >= 0)
                    {
                        CreatureType creatureType = source.ElementAt(randomWeightedItem);
                        creatureType.SpawnFunction(creatureType, spawnPoint.Value);
                    }
                }
            }
        }

        public new void Update(float dt)
        {
            if (CommonLib.WorkType == WorkType.Client || m_subsystemGameInfo.WorldSettings.EnvironmentBehaviorMode != 0)
            {
                return;
            }

            if (m_newSpawnChunks.Count > 0)
            {
                m_newSpawnChunks.RandomShuffle((int max) => m_random.Int(0, max - 1));
                foreach (SpawnChunk newSpawnChunk in m_newSpawnChunks)
                {
                    SpawnChunkCreatures(newSpawnChunk, 10, constantSpawn: false);
                }

                m_newSpawnChunks.Clear();
            }

            if (m_spawnChunks.Count > 0)
            {
                m_spawnChunks.RandomShuffle((int max) => m_random.Int(0, max - 1));
                foreach (SpawnChunk spawnChunk in m_spawnChunks)
                {
                    SpawnChunkCreatures(spawnChunk, 2, constantSpawn: true);
                }

                m_spawnChunks.Clear();
            }

            if (m_subsystemTime.PeriodicGameTimeEvent(60.0, 2.0))
            {
                SpawnRandomCreature();
            }

            if (m_subsystemTime.PeriodicGameTimeEvent(100.0, 2.0))
            {
                SpawnRandomCreature();
            }
        }

        public override void Load(ValuesDictionary valuesDictionary)
        {
            m_subsystemGameInfo = base.Project.FindSubsystem<SubsystemGameInfo>(throwOnError: true);
            m_subsystemSpawn = base.Project.FindSubsystem<SubsystemSpawn>(throwOnError: true);
            m_subsystemTerrain = base.Project.FindSubsystem<SubsystemTerrain>(throwOnError: true);
            m_subsystemTime = base.Project.FindSubsystem<SubsystemTime>(throwOnError: true);
            m_subsystemSky = base.Project.FindSubsystem<SubsystemSky>(throwOnError: true);
            m_subsystemBodies = base.Project.FindSubsystem<SubsystemBodies>(throwOnError: true);
            m_subsystemViews = base.Project.FindSubsystem<SubsystemGameWidgets>(throwOnError: true);
            InitializeCreatureTypes();
            m_subsystemSpawn.SpawningChunk += delegate (SpawnChunk chunk)
            {
                m_spawnChunks.Add(chunk);
                if (!chunk.IsSpawned)
                {
                    m_newSpawnChunks.Add(chunk);
                }
            };
        }

        public new void InitializeCreatureTypes()
        {
            m_creatureTypes.Add(new CreatureType("Duck", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num102 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int humidity30 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int temperature42 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int num103 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    int topHeight5 = m_subsystemTerrain.Terrain.GetTopHeight(point.X, point.Z);
                    return (humidity30 > 8 && temperature42 > 4 && num102 > 30f && point.Y >= topHeight5 && (BlocksManager.Blocks[num103] is LeavesBlock || num103 == 18 || num103 == 8 || num103 == 2)) ? 2.5f : 0f;
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Duck", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Raven", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num100 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature41 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int humidity29 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num101 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    int topHeight4 = m_subsystemTerrain.Terrain.GetTopHeight(point.X, point.Z);
                    return ((humidity29 <= 8 || temperature41 <= 4) && num100 > 30f && point.Y >= topHeight4 && (BlocksManager.Blocks[num101] is LeavesBlock || num101 == 62 || num101 == 8 || num101 == 2 || num101 == 7)) ? 2.5f : 0f;
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Raven", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Seagull", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num98 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int num99 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    int topHeight3 = m_subsystemTerrain.Terrain.GetTopHeight(point.X, point.Z);
                    return (num98 > -100f && num98 < 40f && point.Y >= topHeight3 && (num99 == 18 || num99 == 7 || num99 == 6 || num99 == 62)) ? 2.5f : 0f;
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Seagull", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Wildboar", SpawnLocationType.Surface, randomSpawn: true, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    int humidity28 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num97 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((humidity28 > 5 && (num97 == 8 || num97 == 2)) ? 0.6f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Wildboar", point, m_random.Int(3, 5)).Count
            });
            m_creatureTypes.Add(new CreatureType("Brown Cattle", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num95 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int humidity27 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int temperature40 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int num96 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((num95 > 20f && humidity27 > 4 && temperature40 >= 8 && point.Y < 70 && (num96 == 8 || num96 == 2)) ? 0.25f : 0f);
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    int x = m_random.Int(3, 5);
                    int count6 = MathUtils.Min(m_random.Int(1, 3), x);
                    int count7 = 2;
                    return (point.X <= 3072 || point.X >= 3622 || point.Z <= 3072 || point.Z >= 3622 || point.Y <= 64) ? (SpawnCreatures(creatureType, "Bull_Brown", point, count6).Count + SpawnCreatures(creatureType, "Cow_Brown", point, count7).Count) : 0;
                }
            });
            m_creatureTypes.Add(new CreatureType("Black Cattle", SpawnLocationType.Surface, randomSpawn: true, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num93 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int humidity26 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int temperature39 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int num94 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((humidity26 > 3 && temperature39 < 10 && (num94 == 8 || num94 == 2)) ? 0.6f : 0f);
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    int num92 = m_random.Int(3, 5);
                    int count4 = 5;
                    int count5 = 2;
                    return (point.X <= 3072 || point.X >= 3622 || point.Z <= 3072 || point.Z >= 3622 || point.Y <= 64) ? (SpawnCreatures(creatureType, "Bull_Black", point, count4).Count + SpawnCreatures(creatureType, "Cow_Black", point, count5).Count) : 0;
                }
            });
            m_creatureTypes.Add(new CreatureType("White Bull", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num90 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int humidity25 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int temperature38 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int num91 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((num90 > 20f && humidity25 > 8 && temperature38 < 4 && point.Y < 70 && (num91 == 8 || num91 == 2)) ? 0.1f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Bull_White", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Gray Wolves", SpawnLocationType.Surface, randomSpawn: true, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    int humidity24 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num89 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((humidity24 > 5 && (num89 == 8 || num89 == 2)) ? 0.6f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Wolf_Gray", point, m_random.Int(3, 5)).Count
            });
            m_creatureTypes.Add(new CreatureType("Coyotes", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num87 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int humidity23 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int temperature37 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int num88 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((num87 > 40f && temperature37 > 8 && humidity23 < 8 && humidity23 >= 2 && point.Y < 100 && num88 == 7) ? 0.075f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Wolf_Coyote", point, m_random.Int(1, 3)).Count
            });
            m_creatureTypes.Add(new CreatureType("Brown Bears", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num85 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature36 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int humidity22 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num86 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((num85 > 40f && humidity22 >= 4 && temperature36 >= 8 && point.Y < 110 && (num86 == 8 || num86 == 2 || num86 == 3)) ? 0.01f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Bear_Brown", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Black Bears", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num83 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature35 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int humidity21 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num84 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((num83 > 40f && humidity21 >= 4 && temperature35 < 8 && point.Y < 120 && (num84 == 8 || num84 == 2 || num84 == 3)) ? 0.1f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Bear_Black", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Polar Bears", SpawnLocationType.Surface, randomSpawn: true, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num81 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature34 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int num82 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((num81 > -40f && temperature34 < 8 && point.Y < 80 && num82 == 62) ? 0.1f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Bear_Polar", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Horses", SpawnLocationType.Surface, randomSpawn: true, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num79 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature33 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int humidity20 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num80 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((num79 > 20f && temperature33 > 3 && humidity20 > 6 && point.Y < 80 && (num80 == 8 || num80 == 2 || num80 == 3)) ? 0.05f : 0f);
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    int temperature32 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int num78 = 0;
                    if (m_random.Float(0f, 1f) < 0.35f)
                    {
                        num78 += SpawnCreatures(creatureType, "Horse_Black", point, 1).Count;
                    }

                    if (m_random.Float(0f, 1f) < 0.5f)
                    {
                        num78 += SpawnCreatures(creatureType, "Horse_Bay", point, 1).Count;
                    }

                    if (m_random.Float(0f, 1f) < 0.5f)
                    {
                        num78 += SpawnCreatures(creatureType, "Horse_Chestnut", point, 1).Count;
                    }

                    if (temperature32 > 8 && m_random.Float(0f, 1f) < 0.3f)
                    {
                        num78 += SpawnCreatures(creatureType, "Horse_Palomino", point, 1).Count;
                    }

                    if (temperature32 < 8 && m_random.Float(0f, 1f) < 0.3f)
                    {
                        num78 += SpawnCreatures(creatureType, "Horse_White", point, 1).Count;
                    }

                    return num78;
                }
            });
            m_creatureTypes.Add(new CreatureType("Camels", SpawnLocationType.Surface, randomSpawn: true, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num76 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature31 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int humidity19 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num77 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((num76 > 20f && temperature31 > 8 && humidity19 < 8 && point.Y < 80 && num77 == 7) ? 0.05f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Camel", point, m_random.Int(1, 2)).Count
            });
            m_creatureTypes.Add(new CreatureType("Donkeys", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num74 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature30 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int num75 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((num74 > 20f && temperature30 > 6 && point.Y < 120 && (num75 == 8 || num75 == 2 || num75 == 3 || num75 == 7)) ? 0.05f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Donkey", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Giraffes", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num72 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature29 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int humidity18 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num73 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((num72 > 20f && temperature29 > 8 && humidity18 > 7 && point.Y < 75 && (num73 == 8 || num73 == 2 || num73 == 3)) ? 0.03f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Giraffe", point, m_random.Int(1, 2)).Count
            });
            m_creatureTypes.Add(new CreatureType("Rhinos", SpawnLocationType.Surface, randomSpawn: true, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num70 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature28 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int humidity17 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num71 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((num70 > 40f && temperature28 > 8 && humidity17 > 7 && point.Y < 90 && (num71 == 8 || num71 == 2 || num71 == 3)) ? 0.04f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Rhino", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Tigers", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num68 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int humidity16 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num69 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((num68 > 40f && humidity16 > 8 && point.Y < 80 && (num69 == 8 || num69 == 2 || num69 == 3 || num69 == 7)) ? 0.025f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Tiger", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("White Tigers", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num66 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature27 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num67 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((num66 > 40f && temperature27 < 2 && point.Y < 90 && (num67 == 8 || num67 == 2 || num67 == 3 || num67 == 7 || num67 == 62)) ? 0.025f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Tiger_White", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Lions", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num64 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature26 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int num65 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((num64 > 40f && temperature26 > 8 && point.Y < 80 && (num65 == 8 || num65 == 2 || num65 == 3 || num65 == 7)) ? 0.05f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Lion", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Jaguars", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num62 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature25 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int humidity15 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num63 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((num62 > 40f && humidity15 > 8 && temperature25 > 8 && point.Y < 100 && (num63 == 8 || num63 == 2 || num63 == 3 || num63 == 7 || num63 == 12)) ? 0.04f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Jaguar", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Leopards", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num60 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature24 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num61 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((num60 > 40f && temperature24 > 8 && point.Y < 120 && (num61 == 8 || num61 == 2 || num61 == 3 || num61 == 7 || num61 == 12)) ? 0.04f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Leopard", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Zebras", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num58 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature23 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int humidity14 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num59 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((num58 > 20f && temperature23 > 8 && humidity14 > 7 && point.Y < 80 && (num59 == 8 || num59 == 2 || num59 == 3)) ? 0.05f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Zebra", point, m_random.Int(1, 2)).Count
            });
            m_creatureTypes.Add(new CreatureType("Gnus", SpawnLocationType.Surface, randomSpawn: true, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num56 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature22 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int num57 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((num56 > 20f && temperature22 > 8 && point.Y < 80 && (num57 == 8 || num57 == 2 || num57 == 3)) ? 0.25f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Gnu", point, m_random.Int(1, 2)).Count
            });
            m_creatureTypes.Add(new CreatureType("Reindeers", SpawnLocationType.Surface, randomSpawn: true, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    int temperature21 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int num55 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((temperature21 < 3 && point.Y < 90 && (num55 == 8 || num55 == 2 || num55 == 3 || num55 == 62)) ? 0.15f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Reindeer", point, m_random.Int(1, 3)).Count
            });
            m_creatureTypes.Add(new CreatureType("Mooses", SpawnLocationType.Surface, randomSpawn: true, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    int temperature20 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int num54 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((temperature20 < 7 && point.Y < 90 && (num54 == 8 || num54 == 2 || num54 == 3 || num54 == 62)) ? 0.1f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Moose", point, m_random.Int(1, 3)).Count
            });
            m_creatureTypes.Add(new CreatureType("Bisons", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    int temperature19 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int humidity13 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num53 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((temperature19 < 10 && humidity13 < 12 && point.Y < 80 && (num53 == 8 || num53 == 2 || num53 == 3 || num53 == 62)) ? 0.1f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Bison", point, m_random.Int(1, 4)).Count
            });
            m_creatureTypes.Add(new CreatureType("Ostriches", SpawnLocationType.Surface, randomSpawn: true, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num51 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature18 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int humidity12 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num52 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((num51 > 20f && temperature18 > 8 && humidity12 < 8 && point.Y < 75 && (num52 == 8 || num52 == 2 || num52 == 7)) ? 0.05f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Ostrich", point, m_random.Int(1, 2)).Count
            });
            m_creatureTypes.Add(new CreatureType("Cassowaries", SpawnLocationType.Surface, randomSpawn: true, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num49 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature17 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int humidity11 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num50 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((temperature17 > 8 && humidity11 < 12 && (num50 == 8 || num50 == 2 || num50 == 7)) ? 0.5f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Cassowary", point, 3).Count
            });
            m_creatureTypes.Add(new CreatureType("Hyenas", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num47 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature16 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int num48 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((num47 > 40f && temperature16 > 8 && point.Y < 80 && (num48 == 8 || num48 == 2 || num48 == 7)) ? 0.05f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Hyena", point, m_random.Int(1, 2)).Count
            });
            m_creatureTypes.Add(new CreatureType("Cave Bears", SpawnLocationType.Cave, randomSpawn: true, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    int num46 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((num46 == 3 || num46 == 67 || num46 == 4 || num46 == 66 || num46 == 2 || num46 == 7) ? 1f : 0f);
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    string templateName11 = ((m_random.Int(0, 1) == 0) ? "Bear_Black" : "Bear_Brown");
                    return SpawnCreatures(creatureType, templateName11, point, 1).Count;
                }
            });
            m_creatureTypes.Add(new CreatureType("Cave Tigers", SpawnLocationType.Cave, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    int num45 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((num45 == 3 || num45 == 67 || num45 == 4 || num45 == 66 || num45 == 2 || num45 == 7) ? 0.25f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Tiger", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Cave Lions", SpawnLocationType.Cave, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    int temperature15 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int humidity10 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num44 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : (((num44 == 3 || num44 == 67 || num44 == 4 || num44 == 66 || num44 == 2 || num44 == 7) && temperature15 > 8 && humidity10 < 8) ? 0.25f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Lion", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Cave Jaguars", SpawnLocationType.Cave, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    int num43 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((num43 == 3 || num43 == 67 || num43 == 4 || num43 == 66 || num43 == 2 || num43 == 7) ? 0.5f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Jaguar", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Cave Leopards", SpawnLocationType.Cave, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    int num42 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((num42 == 3 || num42 == 67 || num42 == 4 || num42 == 66 || num42 == 2 || num42 == 7) ? 0.25f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Leopard", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Cave Hyenas", SpawnLocationType.Cave, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    int temperature14 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int num41 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : (((num41 == 3 || num41 == 67 || num41 == 4 || num41 == 66 || num41 == 2 || num41 == 7) && temperature14 > 8) ? 1f : 0f);
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Hyena", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Bull Sharks", SpawnLocationType.Water, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = (CreatureType creatureType, Point3 point) => (!(m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z) < -2f)) ? 0f : 0.4f,
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    string templateName10 = "Shark_Bull";
                    return SpawnCreatures(creatureType, templateName10, point, 1).Count;
                }
            });
            m_creatureTypes.Add(new CreatureType("Tiger Sharks", SpawnLocationType.Water, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = (CreatureType creatureType, Point3 point) => (!(m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z) < -5f)) ? 0f : 0.3f,
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    string templateName9 = "Shark_Tiger";
                    return SpawnCreatures(creatureType, templateName9, point, 1).Count;
                }
            });
            m_creatureTypes.Add(new CreatureType("Great White Sharks", SpawnLocationType.Water, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = (CreatureType creatureType, Point3 point) => (!(m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z) < -20f)) ? 0f : 0.2f,
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    string templateName8 = "Shark_GreatWhite";
                    return SpawnCreatures(creatureType, templateName8, point, 1).Count;
                }
            });
            m_creatureTypes.Add(new CreatureType("Barracudas", SpawnLocationType.Water, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = (CreatureType creatureType, Point3 point) => (!(m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z) < -2f)) ? 0f : 0.5f,
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    string templateName7 = "Barracuda";
                    return SpawnCreatures(creatureType, templateName7, point, 1).Count;
                }
            });
            m_creatureTypes.Add(new CreatureType("Bass_Sea", SpawnLocationType.Water, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = (CreatureType creatureType, Point3 point) => (!(m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z) < -2f)) ? 0f : 1f,
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    string templateName6 = "Bass_Sea";
                    return SpawnCreatures(creatureType, templateName6, point, 1).Count;
                }
            });
            m_creatureTypes.Add(new CreatureType("Bass_Freshwater", SpawnLocationType.Water, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num40 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature13 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    return (num40 > 10f && temperature13 >= 4) ? 1f : 0f;
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    string templateName5 = "Bass_Freshwater";
                    return SpawnCreatures(creatureType, templateName5, point, m_random.Int(1, 2)).Count;
                }
            });
            m_creatureTypes.Add(new CreatureType("Rays", SpawnLocationType.Water, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = (CreatureType creatureType, Point3 point) => (!(m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z) < 10f)) ? 1f : 0.5f,
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    int num37 = 0;
                    int num38 = 0;
                    for (int i = point.X - 2; i <= point.X + 2; i++)
                    {
                        for (int j = point.Z - 2; j <= point.Z + 2; j++)
                        {
                            if (m_subsystemTerrain.Terrain.GetCellContents(point.X, point.Y, point.Z) == 18)
                            {
                                for (int num39 = point.Y - 1; num39 > 0; num39--)
                                {
                                    switch (m_subsystemTerrain.Terrain.GetCellContents(point.X, num39, point.Z))
                                    {
                                        case 2:
                                            num37++;
                                            break;
                                        case 7:
                                            num38++;
                                            break;
                                        default:
                                            continue;
                                    }

                                    break;
                                }
                            }
                        }
                    }

                    string templateName4 = ((num37 >= num38) ? "Ray_Brown" : "Ray_Yellow");
                    return SpawnCreatures(creatureType, templateName4, point, 2).Count;
                }
            });
            m_creatureTypes.Add(new CreatureType("Piranhas", SpawnLocationType.Water, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num36 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int humidity9 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int temperature12 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    return (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64) ? 0f : ((num36 > 10f && humidity9 >= 4 && temperature12 >= 7) ? 1f : 0f);
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    string templateName3 = "Piranha";
                    return SpawnCreatures(creatureType, templateName3, point, m_random.Int(2, 4)).Count;
                }
            });
            m_creatureTypes.Add(new CreatureType("Orcas", SpawnLocationType.Water, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num35 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    if (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64)
                    {
                        return 0f;
                    }

                    return (num35 < -100f) ? 0.05f : ((num35 < -20f) ? 0.01f : 0f);
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    string templateName2 = "Orca";
                    return SpawnCreatures(creatureType, templateName2, point, 1).Count;
                }
            });
            m_creatureTypes.Add(new CreatureType("Belugas", SpawnLocationType.Water, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    if (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64)
                    {
                        return 0f;
                    }

                    float num34 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    return (num34 < -100f) ? 0.05f : ((num34 < -20f) ? 0.01f : 0f);
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    string templateName = "Beluga";
                    return SpawnCreatures(creatureType, templateName, point, 1).Count;
                }
            });
            m_creatureTypes.Add(new CreatureType("Constant Gray Wolves", SpawnLocationType.Surface, randomSpawn: true, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    if (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64)
                    {
                        return 0f;
                    }

                    if (m_subsystemSky.SkyLightIntensity < 0.1f)
                    {
                        float num31 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int humidity8 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                        float num32 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                        int num33 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        int cellLightFast10 = m_subsystemTerrain.Terrain.GetCellLightFast(point.X, point.Y + 1, point.Z);
                        if (((num31 > 20f && humidity8 >= 5) || (num32 <= 10f && point.Y < 90 && cellLightFast10 <= 7)) && (num33 == 8 || num33 == 2))
                        {
                            return 2f;
                        }
                    }

                    return 0f;
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Wolf_Gray", point, m_random.Int(2, 5)).Count
            });
            m_creatureTypes.Add(new CreatureType("Constant Coyotes", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    if (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64)
                    {
                        return 0f;
                    }

                    if (m_subsystemSky.SkyLightIntensity < 0.1f)
                    {
                        float num27 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        float num28 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                        float num29 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                        int num30 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        int cellLightFast9 = m_subsystemTerrain.Terrain.GetCellLightFast(point.X, point.Y + 1, point.Z);
                        if (num27 > 20f && num29 > 8f && num28 < 8f && point.Y < 90 && cellLightFast9 <= 7 && num30 == 7)
                        {
                            return 2f;
                        }
                    }

                    return 0f;
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Wolf_Coyote", point, m_random.Int(1, 3)).Count
            });
            m_creatureTypes.Add(new CreatureType("Constant Brown Bears", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    if (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64)
                    {
                        return 0f;
                    }

                    if (m_subsystemSky.SkyLightIntensity < 0.1f)
                    {
                        float num25 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int temperature11 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                        int humidity7 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                        int num26 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        int cellLightFast8 = m_subsystemTerrain.Terrain.GetCellLightFast(point.X, point.Y + 1, point.Z);
                        if (num25 > 20f && humidity7 >= 4 && temperature11 >= 8 && point.Y < 100 && cellLightFast8 <= 7 && (num26 == 8 || num26 == 2 || num26 == 3))
                        {
                            return 0.5f;
                        }
                    }

                    return 0f;
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Bear_Brown", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Constant Black Bears", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    if (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64)
                    {
                        return 0f;
                    }

                    if (m_subsystemSky.SkyLightIntensity < 0.1f)
                    {
                        float num23 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int temperature10 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                        m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                        int num24 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        int cellLightFast7 = m_subsystemTerrain.Terrain.GetCellLightFast(point.X, point.Y + 1, point.Z);
                        if (num23 > 20f && temperature10 < 8 && point.Y < 110 && cellLightFast7 <= 7 && (num24 == 8 || num24 == 2 || num24 == 3))
                        {
                            return 0.5f;
                        }
                    }

                    return 0f;
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Bear_Black", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Constant Polar Bears", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    if (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64)
                    {
                        return 0f;
                    }

                    if (m_subsystemSky.SkyLightIntensity < 0.1f)
                    {
                        float num21 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int temperature9 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                        int num22 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        int cellLightFast6 = m_subsystemTerrain.Terrain.GetCellLightFast(point.X, point.Y + 1, point.Z);
                        if (num21 > -40f && temperature9 < 8 && point.Y < 90 && cellLightFast6 <= 7 && num22 == 62)
                        {
                            return 0.25f;
                        }
                    }

                    return 0f;
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Bear_Black", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Constant Tigers", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    if (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64)
                    {
                        return 0f;
                    }

                    if (m_subsystemSky.SkyLightIntensity < 0.1f)
                    {
                        float num19 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int humidity6 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                        int num20 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        int cellLightFast5 = m_subsystemTerrain.Terrain.GetCellLightFast(point.X, point.Y + 1, point.Z);
                        if (num19 > 20f && humidity6 > 8 && point.Y < 90 && cellLightFast5 <= 7 && (num20 == 8 || num20 == 2 || num20 == 3))
                        {
                            return 0.05f;
                        }
                    }

                    return 0f;
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Tiger", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Constant Lions", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    if (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64)
                    {
                        return 0f;
                    }

                    if (m_subsystemSky.SkyLightIntensity < 0.1f)
                    {
                        float num17 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int temperature8 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                        int num18 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        int cellLightFast4 = m_subsystemTerrain.Terrain.GetCellLightFast(point.X, point.Y + 1, point.Z);
                        if (num17 > 20f && temperature8 > 8 && point.Y < 90 && cellLightFast4 <= 7 && (num18 == 8 || num18 == 2 || num18 == 3 || num18 == 7))
                        {
                            return 0.25f;
                        }
                    }

                    return 0f;
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Lion", point, m_random.Int(1, 2)).Count
            });
            m_creatureTypes.Add(new CreatureType("Constant Jaguars", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    if (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64)
                    {
                        return 0f;
                    }

                    if (m_subsystemSky.SkyLightIntensity < 0.1f)
                    {
                        float num15 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int temperature7 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                        int humidity5 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                        int num16 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        int cellLightFast3 = m_subsystemTerrain.Terrain.GetCellLightFast(point.X, point.Y + 1, point.Z);
                        if (num15 > 20f && temperature7 > 8 && humidity5 > 8 && point.Y < 100 && cellLightFast3 <= 7 && (num16 == 8 || num16 == 2 || num16 == 3 || num16 == 12))
                        {
                            return 0.25f;
                        }
                    }

                    return 0f;
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Jaguar", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Constant Leopards", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    if (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64)
                    {
                        return 0f;
                    }

                    if (m_subsystemSky.SkyLightIntensity < 0.1f)
                    {
                        float num13 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int temperature6 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                        int num14 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        int cellLightFast2 = m_subsystemTerrain.Terrain.GetCellLightFast(point.X, point.Y + 1, point.Z);
                        if (num13 > 20f && temperature6 > 8 && point.Y < 110 && cellLightFast2 <= 7 && (num14 == 8 || num14 == 2 || num14 == 3 || num14 == 12))
                        {
                            return 0.25f;
                        }
                    }

                    return 0f;
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Leopard", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Constant Hyenas", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    if (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64)
                    {
                        return 0f;
                    }

                    if (m_subsystemSky.SkyLightIntensity < 0.1f)
                    {
                        float num11 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                        int temperature5 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                        int num12 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                        int cellLightFast = m_subsystemTerrain.Terrain.GetCellLightFast(point.X, point.Y + 1, point.Z);
                        if (num11 > 20f && temperature5 > 8 && point.Y < 100 && cellLightFast <= 7 && (num12 == 8 || num12 == 2 || num12 == 3 || num12 == 7))
                        {
                            return 1f;
                        }
                    }

                    return 0f;
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Hyena", point, m_random.Int(1, 2)).Count
            });
            m_creatureTypes.Add(new CreatureType("Pigeon", SpawnLocationType.Surface, randomSpawn: true, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    if (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64)
                    {
                        return 0f;
                    }

                    float num9 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature4 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num10 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    int topHeight2 = m_subsystemTerrain.Terrain.GetTopHeight(point.X, point.Z);
                    return (temperature4 > 3 && num9 > 30f && point.Y >= topHeight2 && (BlocksManager.Blocks[num10] is LeavesBlock || num10 == 8 || num10 == 2 || num10 == 7)) ? 1.5f : 0f;
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Pigeon", point, 1).Count
            });
            m_creatureTypes.Add(new CreatureType("Sparrow", SpawnLocationType.Surface, randomSpawn: false, constantSpawn: false)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    if (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64)
                    {
                        return 0f;
                    }

                    float num7 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int temperature3 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num8 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    int topHeight = m_subsystemTerrain.Terrain.GetTopHeight(point.X, point.Z);
                    return (temperature3 > 3 && num7 > 20f && point.Y >= topHeight && (BlocksManager.Blocks[num8] is LeavesBlock || num8 == 8 || num8 == 2 || num8 == 7)) ? 2f : 0f;
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    int count3 = m_random.Int(1, 2);
                    return SpawnCreatures(creatureType, "Sparrow", point, count3).Count;
                }
            });
            m_creatureTypes.Add(new CreatureType("Cave Spider", SpawnLocationType.Cave, randomSpawn: true, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    int temperature2 = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int humidity4 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num6 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return ((num6 != 3 && num6 != 67 && num6 != 4 && num6 != 66 && num6 != 2 && num6 != 7) || temperature2 <= 2 || humidity4 < 2) ? 0f : 0.85f;
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "Cave_Spider", point, m_random.Int(1, 3)).Count
            });
            m_creatureTypes.Add(new CreatureType("Zombie", SpawnLocationType.Cave, randomSpawn: false, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    int temperature = m_subsystemTerrain.Terrain.GetTemperature(point.X, point.Z);
                    int humidity3 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num5 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    return (num5 != 3 && num5 != 67 && num5 != 4 && num5 != 66 && num5 != 2 && num5 != 7) ? 0f : 0.85f;
                },
                SpawnFunction = (CreatureType creatureType, Point3 point) => SpawnCreatures(creatureType, "StrongZombie1_Strength", point, m_random.Int(1, 2)).Count
            });
            m_creatureTypes.Add(new CreatureType("surface Zombie", SpawnLocationType.Surface, randomSpawn: true, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num3 = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int humidity2 = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num4 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    if (num3 > 20f && point.Y > 64 && (num4 == 8 || num4 == 2 || num4 == 3 || num4 == 7 || num4 == 67))
                    {
                        if (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64)
                        {
                            if (point.X > 3425 && point.X < 3517 && point.Z > 3168 && point.Z < 3273 && point.Y > 64)
                            {
                                return 0.05f;
                            }

                            if (point.X > 3072 && point.X < 3197 && point.Z > 3072 && point.Z < 3212 && point.Y > 64)
                            {
                                return 0f;
                            }

                            return 1000f;
                        }

                        if (point.X > 1018 && point.X < 1590 && point.Z > 1018 && point.Z < 1590)
                        {
                            return 100f;
                        }

                        return 0.25f;
                    }

                    return 0f;
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    int count2 = m_random.Int(1, 2);
                    if (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64)
                    {
                        count2 = ((point.X > 3425 && point.X < 3517 && point.Z > 3168 && point.Z < 3273 && point.Y > 64) ? 1 : ((point.X <= 3072 || point.X >= 3197 || point.Z <= 3072 || point.Z >= 3212 || point.Y <= 64) ? 5 : 0));
                    }
                    else if (point.X > 1018 && point.X < 1590 && point.Z > 1018 && point.Z < 1590)
                    {
                        count2 = 5;
                    }

                    return SpawnCreatures(creatureType, "StrongZombie1_Strength", point, count2).Count;
                }
            });
            m_creatureTypes.Add(new CreatureType("surface Shigui", SpawnLocationType.Surface, randomSpawn: true, constantSpawn: true)
            {
                SpawnSuitabilityFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    float num = m_subsystemTerrain.TerrainContentsGenerator.CalculateOceanShoreDistance(point.X, point.Z);
                    int humidity = m_subsystemTerrain.Terrain.GetHumidity(point.X, point.Z);
                    int num2 = Terrain.ExtractContents(m_subsystemTerrain.Terrain.GetCellValueFast(point.X, point.Y - 1, point.Z));
                    if (num > 20f && point.Y > 64 && (num2 == 8 || num2 == 2 || num2 == 3 || num2 == 7 || num2 == 67))
                    {
                        if (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64)
                        {
                            if (point.X > 3425 && point.X < 3517 && point.Z > 3168 && point.Z < 3273 && point.Y > 64)
                            {
                                return 0.05f;
                            }

                            if (point.X > 3072 && point.X < 3197 && point.Z > 3072 && point.Z < 3212 && point.Y > 64)
                            {
                                return 0f;
                            }

                            return 1000f;
                        }

                        if (point.X > 1018 && point.X < 1590 && point.Z > 1018 && point.Z < 1590)
                        {
                            return 0f;
                        }

                        return 0f;
                    }

                    return 0f;
                },
                SpawnFunction = delegate (CreatureType creatureType, Point3 point)
                {
                    int count = m_random.Int(1, 3);
                    if (point.X > 3072 && point.X < 3622 && point.Z > 3072 && point.Z < 3622 && point.Y > 64)
                    {
                        count = ((point.X > 3425 && point.X < 3517 && point.Z > 3168 && point.Z < 3273 && point.Y > 64) ? 1 : ((point.X <= 3072 || point.X >= 3197 || point.Z <= 3072 || point.Z >= 3212 || point.Y <= 64) ? 4 : 0));
                    }
                    else if (point.X > 1018 && point.X < 1590 && point.Z > 1018 && point.Z < 1590)
                    {
                        count = 0;
                    }

                    return SpawnCreatures(creatureType, "Shigui", point, count).Count;
                }
            });
            ModsManager.HookAction("InitializeCreatureTypes", delegate (ModLoader loader)
            {
                loader.InitializeCreatureTypes(this, m_creatureTypes);
                return false;
            });
        }
    }
}